
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<%-- 导入面包屑 --%>
<jsp:include page="../common/nav.jsp"></jsp:include>

<div class="wrapper wrapper-content animated fadeInRight">

    <%-- 导入提示信息框 --%>
    <c:if test="${hint!=null&&hint!=''}">
   		<jsp:include page="../common/alert/alert.jsp">
   			<jsp:param value="${hint}" name="alertType"/>
   			<jsp:param value="${alertMessage}" name="alertMessage"/>
   		</jsp:include>
    </c:if>

	<%-- 导入查询框 --%>
	<jsp:include page="search/mdMaterialSearch.jsp"></jsp:include>
	<%--数据导入--%>
	<jsp:include page="pop/batchImportOfMaterial.jsp"></jsp:include>

	<div class="row">
		<div class="col-lg-12">
			<div class="ibox ">
				<div class="ibox-title">
					<h4>物料与服务列表</h4>
					<div class="ibox-tools">
						<button id="addButton" class="btn btn-success btn-sm" type="button"><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">新增物料/服务</span></button>
						<button id="searchButton" class="btn btn-default btn-sm btn-notcontrol" type="button"><i class="fa fa-search"></i>&nbsp;&nbsp;展开查询</button>
						<button id="exportListButton" class="btn btn-sm btn-notcontrol" type="button"><i class="fa fa-download"></i>&nbsp;&nbsp;导出表格</button>
						<button id="importListButton" class="btn btn-sm btn-notcontrol" type="button"><i class="fa fa-upload"></i>&nbsp;&nbsp;批量导入</button>
					</div>
				</div>
				<div class="ibox-content border-bottom" style="padding-bottom: 0px;">
					<div class="table-responsive">
						<table class="table table-striped table-hover table-bordered border-top">
							<thead>
							<tr>
								<%--
                                <th></th>
                                --%>
								<th width="5%">序号</th>
								<th>物料/服务</th>
								<th>物料/服务编码</th>
								<th>物料/服务名称</th>
								<th>物料/服务类别</th>
								<th>规格型号</th>
								<th width="7%">品牌</th>
								<th>单位</th>
								<th>创建人</th>
								<th>创建时间</th>
								<th width="5%">状态</th>
								<th width="7%">审批状态</th>
							</tr>
							</thead>
							<tbody>

							    <c:forEach items="${requestScope.mdMaterialList}" var="data" varStatus="status">
								<tr>
									<td>${status.count}</td>
									<td>${requestScope.materialTypeMap[data.materialType]}</td>
									<td>${data.materialCode}</td>
									<td>${data.materialName}</td>
									<td>${data.categoryDesc}</td>
									<td>${data.standard}</td>
									<td>${data.brand}</td>
									<td>${requestScope.materialUnitMap[data.materialUnit]}</td>
									<td>${data.createdBy}</td>
									<td><fmt:formatDate value="${data.createdDate}" pattern="yyyy-MM-dd"/></td>
									<td>
										<c:choose>
											<c:when test="${data.status=='Y'}">
												<span class="label label-primary">有效</span>
											</c:when>
											<c:otherwise>
												<span class="label label-danger">无效</span>
											</c:otherwise>
										</c:choose>
									</td>
									<td>
										<div class="btn-group">
											<button class="btn-white btn btn-xs btn-notcontrol" onclick="editData(${data.materialId})"><i class="fa fa-edit"></i>&nbsp;编辑</button>&nbsp;
											<button class="btn-white btn btn-xs" onclick="deleteData(${data.materialId})"><i class="fa fa-trash"></i>&nbsp;删除</button>
										</div>
									</td>
								</tr>
								</c:forEach>

							</tbody>
							<tfoot>
							    <%-- 导入页码 --%>
								<jsp:include page="../common/pages.jsp"></jsp:include>
							</tfoot>
						</table>
					</div>

				</div>
			</div>
		</div>

	</div>
</div>
<!-- listPage -->
<script src="js/listPage.js"></script>
<script>
    $(document).ready(function() {
        $("#addButton").click(function(){
            window.location.href="web/mdMaterial/getMdMaterial";
        });

    });

    function editData(id){
        window.location.href="web/mdMaterial/getMdMaterial?materialId="+id;
    }

    function deleteData(id) {
        redragonJS.confirm("确认删除数据？", function(){
            window.location.href="web/mdMaterial/deleteMdMaterial?materialId="+id;
        });
    }
    $("#importListButton").click(function(){
        $('#batchImportDiv').modal('show');
    });
</script>       